/*
 * Copyright (c) 2016- 2020 qolome.com Inc. All Rights Reserved.
 * ProjectName: qolome-knowledge
 * FileName: ClassAssist.java
 * Author: jiangfeng@qolome.com
 * Date: 2020/3/4 下午3:50
 * LastModified: 2020/03/04 15:50:04
 */

package com.qolome.knowledge.design.pattern.proxy.demo.classes;

/**
 * @author Qolome
 * @version V1.0
 * @Description 类辅助器
 * @date 2020年 03月04日 15:50:45
 */
public class ClassAssist {

    public static String getReturnPackageType(Class<?> value) {
        if(isLong(value)){
            return "(Long)";
        }else if(isInteger(value)){
            return "(Integer)";
        }else if(isShort(value)){
            return "(Short)";
        }else if(isByte(value)){
            return "(Byte)";
        }else if(isDouble(value)){
            return "(Double)";
        }else if(isFloat(value)){
            return "(Float)";
        }else if(String.class==value){
            return "(String)";
        }
        return "";
    }

    public static String getReturnConvert(Class<?> value) {

        if(String.class==value){
            return ".toString()";
        }else if(isDouble(value)){
            return ".doubleValue()";
        }else if(isFloat(value)){
            return ".floatValue()";
        }else if(isByte(value)){
            return ".byteValue()";
        }else if(isShort(value)){
            return ".shortValue()";
        }else if(isInteger(value)){
            return ".intValue()";
        }else if(isLong(value)){
            return ".longValue()";
        }

        return "";
    }

        public static boolean isDouble(Class<?> value){
        return double.class==value|| Double.class==value;
        }
    public static boolean isFloat(Class<?> value){
        return float.class==value|| Float.class==value;
    }
    public static boolean isByte(Class<?> value){
        return byte.class==value|| Byte.class==value;
    }
    public static boolean isInteger(Class<?> value){
        return int.class==value|| Integer.class==value;
    }
    public static boolean isShort(Class<?> value){
        return short.class==value|| Short.class==value;
    }
    public static boolean isLong(Class<?> value){
        return long.class==value || Long.class==value;
    }

}
